package com.quyeying.service.impl;

import com.quyeying.entity.SysPlatformConfigEntity;
import com.quyeying.mapper.SysPlatformConfigDao;
import com.quyeying.service.SysPlatformConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.quyeying.utils.result.R;
import com.quyeying.utils.result.ReturnPageData;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

/**
* <p>
 * 平台配置 服务实现类
 * </p>
*
* @author skx
* @since 2022-07-18
*/
@Service
public class SysPlatformConfigServiceImpl extends ServiceImpl<SysPlatformConfigDao, SysPlatformConfigEntity> implements SysPlatformConfigService {

    @Override
    public R findListByPage(Integer page, Integer pageCount){
        IPage<SysPlatformConfigEntity> wherePage = new Page<>(page, pageCount);
        SysPlatformConfigEntity where = new SysPlatformConfigEntity();
        IPage<SysPlatformConfigEntity> iPage = baseMapper.selectPage(wherePage, Wrappers.query(where));
        return R.success(ReturnPageData.fillingData(iPage));
    }

    @Override
    public R add(SysPlatformConfigEntity sysPlatformConfigEntity){
        baseMapper.insert(sysPlatformConfigEntity);
        return R.success();
    }

    @Override
    public R delete(Long id){
        baseMapper.deleteById(id);
        return R.success();
    }

    @Override
    public R updateData(SysPlatformConfigEntity sysPlatformConfigEntity){
        baseMapper.updateById(sysPlatformConfigEntity);
        return R.success();
    }

    @Override
    public R findById(Long id){
        SysPlatformConfigEntity sysPlatformConfigEntity = baseMapper.selectById(id);
        return R.success(sysPlatformConfigEntity);
    }
}
